// 城市坐标数据
export const cityCoordinates: { [key: string]: [number, number] } = {
  // 江西省各市区详细坐标
  南昌市: [115.892151, 28.676493],
  南昌县: [115.892151, 28.676493],
  新建区: [115.892151, 28.676493],
  东湖区: [115.892151, 28.676493],
  西湖区: [115.892151, 28.676493],
  青云谱区: [115.892151, 28.676493],
  湾里区: [115.892151, 28.676493],
  青山湖区: [115.892151, 28.676493],
  红谷滩区: [115.892151, 28.676493],
  安义县: [115.892151, 28.676493],
  进贤县: [115.892151, 28.676493],

  九江市: [115.992811, 29.719055],
  浔阳区: [115.992811, 29.719055],
  濂溪区: [115.992811, 29.719055],
  柴桑区: [115.992811, 29.719055],
  武宁县: [115.992811, 29.719055],
  修水县: [115.992811, 29.719055],
  永修县: [115.992811, 29.719055],
  德安县: [115.992811, 29.719055],
  都昌县: [115.992811, 29.719055],
  湖口县: [115.992811, 29.719055],
  彭泽县: [115.992811, 29.719055],
  瑞昌市: [115.992811, 29.719055],
  共青城市: [115.992811, 29.719055],
  庐山市: [115.992811, 29.719055],

  上饶市: [117.971185, 28.44442],
  信州区: [117.971185, 28.44442],
  广丰区: [117.971185, 28.44442],
  广信区: [117.971185, 28.44442],
  玉山县: [117.971185, 28.44442],
  铅山县: [117.971185, 28.44442],
  横峰县: [117.971185, 28.44442],
  弋阳县: [117.971185, 28.44442],
  余干县: [117.971185, 28.44442],
  鄱阳县: [117.971185, 28.44442],
  万年县: [117.971185, 28.44442],
  婺源县: [117.971185, 28.44442],
  德兴市: [117.971185, 28.44442],

  抚州市: [116.358351, 27.98385],
  临川区: [116.358351, 27.98385],
  东乡区: [116.358351, 27.98385],
  南城县: [116.358351, 27.98385],
  黎川县: [116.358351, 27.98385],
  南丰县: [116.358351, 27.98385],
  崇仁县: [116.358351, 27.98385],
  乐安县: [116.358351, 27.98385],
  宜黄县: [116.358351, 27.98385],
  金溪县: [116.358351, 27.98385],
  资溪县: [116.358351, 27.98385],
  广昌县: [116.358351, 27.98385],

  宜春市: [114.391136, 27.8043],
  袁州区: [114.391136, 27.8043],
  奉新县: [114.391136, 27.8043],
  万载县: [114.391136, 27.8043],
  上高县: [114.391136, 27.8043],
  宜丰县: [114.391136, 27.8043],
  靖安县: [114.391136, 27.8043],
  铜鼓县: [114.391136, 27.8043],
  丰城市: [114.391136, 27.8043],
  樟树市: [114.391136, 27.8043],
  高安市: [114.391136, 27.8043],

  吉安市: [114.979793, 27.11117],
  吉州区: [114.979793, 27.11117],
  青原区: [114.979793, 27.11117],
  吉安县: [114.979793, 27.11117],
  吉水县: [114.979793, 27.11117],
  峡江县: [114.979793, 27.11117],
  新干县: [114.979793, 27.11117],
  永丰县: [114.979793, 27.11117],
  泰和县: [114.979793, 27.11117],
  遂川县: [114.979793, 27.11117],
  万安县: [114.979793, 27.11117],
  安福县: [114.979793, 27.11117],
  永新县: [114.979793, 27.11117],
  井冈山市: [114.979793, 27.11117],

  赣州市: [114.934264, 25.845296],
  章贡区: [114.934264, 25.845296],
  南康区: [114.934264, 25.845296],
  赣县区: [114.934264, 25.845296],
  信丰县: [114.934264, 25.845296],
  大余县: [114.934264, 25.845296],
  上犹县: [114.934264, 25.845296],
  崇义县: [114.934264, 25.845296],
  安远县: [114.934264, 25.845296],
  龙南县: [114.934264, 25.845296],
  定南县: [114.934264, 25.845296],
  全南县: [114.934264, 25.845296],
  宁都县: [114.934264, 25.845296],
  于都县: [114.934264, 25.845296],
  兴国县: [114.934264, 25.845296],
  会昌县: [114.934264, 25.845296],
  寻乌县: [114.934264, 25.845296],
  石城县: [114.934264, 25.845296],
  瑞金市: [114.934264, 25.845296],

  景德镇市: [117.178919, 29.268835],
  珠山区: [117.178919, 29.268835],
  昌江区: [117.178919, 29.268835],
  浮梁县: [117.178919, 29.268835],
  乐平市: [117.178919, 29.268835],

  萍乡市: [113.852186, 27.622946],
  安源区: [113.852186, 27.622946],
  湘东区: [113.852186, 27.622946],
  莲花县: [113.852186, 27.622946],
  上栗县: [113.852186, 27.622946],
  芦溪县: [113.852186, 27.622946],

  新余市: [114.930832, 27.8043],
  渝水区: [114.930832, 27.8043],
  分宜县: [114.930832, 27.8043],

  鹰潭市: [117.033838, 28.238638],
  月湖区: [117.033838, 28.238638],
  余江区: [117.033838, 28.238638],
  贵溪市: [117.033838, 28.238638],

  // 其他省份主要城市
  上海市: [121.472644, 31.231706],
  广州市: [113.280637, 23.125178],
  武汉市: [114.298572, 30.584355],
  南京市: [118.767413, 32.041544],
  重庆市: [106.504962, 29.533155],
  北京市: [116.397428, 39.90923],
  天津市: [117.190182, 39.125596],
  河北省: [114.502461, 38.045474],
  山西省: [112.549248, 37.857014],
  内蒙古自治区: [111.670801, 40.818311],
  辽宁省: [123.429096, 41.796767],
  吉林省: [125.3245, 43.886841],
  黑龙江省: [126.642464, 45.756967],
  江苏省: [118.767413, 32.041544],
  浙江省: [120.153576, 30.287459],
  安徽省: [117.283042, 31.86119],
  福建省: [119.306239, 26.075302],
  山东省: [117.000923, 36.675807],
  河南省: [113.665412, 34.757975],
  湖北省: [114.298572, 30.584355],
  湖南省: [112.982279, 28.19409],
  广东省: [113.280637, 23.125178],
  广西壮族自治区: [108.320004, 22.82402],
  海南省: [110.33119, 20.031971],
  四川省: [104.065735, 30.659462],
  贵州省: [106.713478, 26.578343],
  云南省: [102.712251, 25.040609],
  西藏自治区: [91.132212, 29.860361],
  陕西省: [108.948024, 34.263161],
  甘肃省: [103.823557, 36.058039],
  青海省: [101.778916, 36.623178],
  宁夏回族自治区: [106.278179, 38.46637],
  新疆维吾尔自治区: [87.617733, 43.792818],
  台湾省: [121.509062, 25.044332],
  香港特别行政区: [114.173355, 22.320048],
  澳门特别行政区: [113.54909, 22.198951],
};

// 默认坐标（北京）
export const defaultCoordinates: [number, number] = [116.397428, 39.90923];

// 根据地址获取坐标的函数
export const getCoordinatesFromAddress = (address: string): [number, number] => {
  if (!address) return defaultCoordinates;

  // 尝试精确匹配
  for (const [cityName, coordinates] of Object.entries(cityCoordinates)) {
    if (address.includes(cityName)) {
      console.log(
        `匹配到地址: ${address} -> ${cityName} -> [${coordinates[0]}, ${coordinates[1]}]`
      );
      return coordinates;
    }
  }

  // 尝试模糊匹配（不区分大小写）
  const addressLower = address.toLowerCase();
  for (const [cityName, coordinates] of Object.entries(cityCoordinates)) {
    if (addressLower.includes(cityName.toLowerCase())) {
      console.log(
        `模糊匹配到地址: ${address} -> ${cityName} -> [${coordinates[0]}, ${coordinates[1]}]`
      );
      return coordinates;
    }
  }

  console.log(`未匹配到地址: ${address}，使用默认坐标`);
  return defaultCoordinates;
};
